package com.iot.dw.job;

import com.iot.core.manager.job.IMyJob;
import com.iot.core.util.MyDateTime;
import com.iot.dw.netty.SocketHandler;
import com.iot.dw.netty.SocketServer;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.Unpooled;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
@Slf4j
public class NetJob implements IMyJob {

    @Override
    public String getJobName() {
        return "netjob";
    }

    @Override
    public String getJobGroup() {
        return "netjob";
    }

    @Override
    public String getJobDesc() {
        return null;
    }

    @Override
    public String getCron() {
        return "*/10 * * * * ?";//5秒
    }

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        log.info( this.getJobName()+":"+ MyDateTime.now() );

        for (var m:SocketHandler.clients
             ) {
            ByteBuf buffer = Unpooled.copiedBuffer( MyDateTime.now().getBytes());
          //  m.writeAndFlush(buffer);
            log.info(m.id().toString()  );
        }

    }
}
